/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
 * MA  02110-1301, USA.
 *
 * http://www.gnu.org/copyleft/gpl.html
 */
package system.teleport;

import com.aionemu.gameserver.model.gameobjects.player.Player;
import com.aionemu.gameserver.network.aion.serverpackets.SM_DIALOG_WINDOW;
import com.aionemu.gameserver.questEngine.QuestEngine;
import com.aionemu.gameserver.questEngine.handlers.QuestHandler;
import com.aionemu.gameserver.questEngine.model.QuestEnv;
import com.aionemu.gameserver.questEngine.model.QuestState;
import com.aionemu.gameserver.questEngine.model.QuestStatus;
import com.aionemu.gameserver.services.TeleportService;
import com.aionemu.gameserver.utils.PacketSendUtility;

/**
 * @author Mr. Poke
 *
 */
public class _1001GoldenTeleport extends QuestHandler
{

	private final static int	questId	= -1001;

	public static void main(String[] args)
	{
		QuestEngine.getInstance().addQuestHandler(new _1001GoldenTeleport());
	}
	/**
	 * @param questId
	 */
	public _1001GoldenTeleport()
	{
		super(questId);
		qe.setNpcQuestData(730268).addOnTalkEvent(questId);
		qe.setNpcQuestData(730269).addOnTalkEvent(questId);
		qe.setNpcQuestData(730265).addOnTalkEvent(questId);
		qe.setNpcQuestData(730266).addOnTalkEvent(questId);
	}

	@Override
	public boolean onDialogEvent(QuestEnv env)
	{
		final Player player = env.getPlayer();
		int questId = 0;
		switch (player.getRace())
		{
			case ASMODIANS:
				questId = 29004;
				break;
			case ELYOS:
				questId = 19004;
				break;
		}
		QuestState qs = player.getQuestStateList().getQuestState(questId);
		switch (env.getDialogId())
		{
			case -1:
				if (qs == null || !(qs.getStatus() == QuestStatus.REWARD || qs.getStatus() == QuestStatus.COMPLETE))
				{
					PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 27));
					return true;
				}
				else
				{
					PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 1011));
					return true;
				}
			case 10000:
				int npcId = env.getVisibleObject().getNpcId();
				switch(npcId)
				{
					case 730268:
						TeleportService.teleportTo(player, 120020000, 1557, 1429, 266, 0);
						return sendQuestDialog(env, 0);
					case 730269:
						TeleportService.teleportTo(player, 120010000, 1603, 1389, 193, 118);
						return sendQuestDialog(env, 0);
					case 730265:
						TeleportService.teleportTo(player, 110020000, 2155, 1567, 1205, 0);
						return sendQuestDialog(env, 0);
					case 730266:
						TeleportService.teleportTo(player, 110010000, 1366, 1541, 569, 92);
						return sendQuestDialog(env, 0);
				}
		}
		
		return false;
	}
}
